package com.example.studentmanagersystem;

import com.example.studentmanagersystem.R;
import com.example.studentmanagersystem.R.id;
import com.example.studentmanagersystem.R.menu;
import com.fs.aboutwe.AboutWeActivity;

import android.content.Context;
import android.content.Intent;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;
import android.widget.Toast;
import android.widget.PopupMenu.OnMenuItemClickListener;

public class PopupMenuUtil {

	private View v;
	private Context context;

	public PopupMenuUtil(View v, Context context) {
		
		this.v=v;
		this.context=context;

	}

	/**
	 * ActionBar, PopuMenu, Button
	 */

	public void actionBackListener() {

		PopupMenu popup = new PopupMenu(context, v);
		// 将R.menu.popup_menu菜单资源加载到popup菜单中
		popup.getMenuInflater().inflate(R.menu.main, popup.getMenu());
		popup.show();// 显示

		popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
			@Override
			public boolean onMenuItemClick(MenuItem item) {// item:事件源
				Intent intent;
				switch (item.getItemId()) {
				case R.id.aboutMe:
					
					intent=new Intent(context, AboutWeActivity.class);
					context.startActivity(intent);
					
					break;
				case R.id.moreFun:
					Toast.makeText(context, "更多功能！", 1).show();
					break;
				case R.id.setting:
					Toast.makeText(context, "设置！", 1).show();
					break;
				}
				return false;
			}
		});

	}

}
